<%--
  Created by IntelliJ IDEA.
  User: zhongge
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
  <title>博客系统 - 注册</title>
  <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/style.css">
  <style>
    /* 基础重置与全局样式 */
    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    body {
      background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
      min-height: 100vh;
      display: flex;
      justify-content: center;
      align-items: center;
      padding: 20px;
    }

    .container {
      background: white;
      border-radius: 12px;
      box-shadow: 0 15px 30px rgba(0, 0, 0, 0.1);
      width: 100%;
      max-width: 500px;
      padding: 40px;
      transition: all 0.3s ease;
    }

    .container:hover {
      box-shadow: 0 20px 35px rgba(0, 0, 0, 0.15);
    }

    h1 {
      color: #2d3748;
      text-align: center;
      margin-bottom: 30px;
      font-weight: 600;
      font-size: 28px;
    }

    /* 错误消息样式 */
    .error {
      padding: 12px 15px;
      border-radius: 8px;
      margin-bottom: 25px;
      font-size: 15px;
      text-align: center;
      background-color: #fed7d7;
      color: #c53030;
      border: 1px solid #feb2b2;
    }

    /* 表单样式 */
    .form-group {
      margin-bottom: 20px;
    }

    label {
      display: block;
      margin-bottom: 8px;
      color: #4a5568;
      font-weight: 500;
      font-size: 15px;
    }

    input[type="text"],
    input[type="password"],
    input[type="email"] {
      width: 100%;
      padding: 14px 16px;
      border: 1px solid #e2e8f0;
      border-radius: 8px;
      font-size: 16px;
      transition: all 0.3s;
      background-color: #f7fafc;
    }

    input[type="text"]:focus,
    input[type="password"]:focus,
    input[type="email"]:focus {
      outline: none;
      border-color: #667eea;
      box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
      background-color: #fff;
    }

    /* 按钮样式 */
    button {
      width: 100%;
      padding: 14px;
      background: #667eea;
      color: white;
      border: none;
      border-radius: 8px;
      font-size: 16px;
      font-weight: 600;
      cursor: pointer;
      transition: all 0.3s;
      margin-bottom: 15px;
    }

    button:hover {
      background: #5a67d8;
      transform: translateY(-2px);
      box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }

    button:active {
      transform: translateY(0);
    }

    /* 登录链接样式 */
    .link {
      display: block;
      text-align: center;
      color: #667eea;
      text-decoration: none;
      font-weight: 500;
      font-size: 15px;
      transition: color 0.3s;
    }

    .link:hover {
      color: #5a67d8;
      text-decoration: underline;
    }

    /* 响应式设计 */
    @media (max-width: 520px) {
      .container {
        padding: 30px 25px;
      }

      h1 {
        font-size: 24px;
      }

      input[type="text"],
      input[type="password"],
      input[type="email"] {
        padding: 12px 14px;
      }

      button {
        padding: 12px;
      }
    }
  </style>
</head>
<body>
<div class="container">
  <h1>用户注册</h1>

  <c:if test="${not empty errorMsg}">
    <div class="error">${errorMsg}</div>
  </c:if>

  <form action="${pageContext.request.contextPath}/user/register" method="post">
    <div class="form-group">
      <label for="username">用户名：</label>
      <input type="text" id="username" name="username"
             value="${user != null ? user.username : ''}" required>
    </div>

    <div class="form-group">
      <label for="password">密码：</label>
      <input type="password" id="password" name="password" required>
    </div>

    <div class="form-group">
      <label for="nickname">昵称：</label>
      <input type="text" id="nickname" name="nickname"
             value="${user != null ? user.nickname : ''}">
    </div>

    <div class="form-group">
      <label for="email">邮箱：</label>
      <input type="email" id="email" name="email"
             value="${user != null ? user.email : ''}">
    </div>

    <div class="form-group">
      <button type="submit">注册</button>
      <a href="${pageContext.request.contextPath}/user/loginPage" class="link">已有账号？登录</a>
    </div>
  </form>
</div>
</body>
</html>